import os

os.system("ls >> ls_log")

with open("ls_log", "r") as f:
    for line in f:
        line = line.strip()
        try:
            if line.split('.')[1] == 'cpp':
                name = line.split('.')[0]
                os.system("mkdir {0}".format(name))
                os.system("mv {0} {1}".format(line, name))
                print(line)
        except IndexError:
            pass

        
os.system("rm ls_log")
